<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content=" height=device-height,
			          width=device-width,
			          initial-scale=1.0,
			          minimum-scale=1.0,
			          maximum-scale=1.0,
			          user-scalable=no" />
		<title>登录</title>
		<script type="text/javascript" src="../js/jquery.min.js" charset="utf-8"></script>
		<link rel="stylesheet" href="../css/login.css" type="text/css" />
		<script type="text/javascript">
			//客户39.108.187.126
			//192.168.1.104
			$(function() {
				localStorage.setItem("ip", 'http://192.168.1.104:8080/wxs/wx/');
				if(localStorage.getItem("userName") != null) {
					document.getElementById('user').value = localStorage.getItem("userName");
					document.getElementById('password').value = localStorage.getItem("password");
				}
				$('#thebuyer').click(function() {
					var userName = document.getElementById('user').value;
					var password = document.getElementById('password').value;
					localStorage.setItem("userName", userName);
					localStorage.setItem("password", password);
					var ip = localStorage.getItem("ip");
					$.ajax({
						type: 'post', //类型
						url: ip + 'user/login', //请求路径
						contentType: 'application/x-www-form-urlencoded', //默认
						dataType: 'json', //返回数据类型  可以是text：字符串  可以是json：json对象
						data: {
							'username': userName,
							'password': password
						}, //数据
						success: function(result) {
							if(result.code == 200) {
								var usertype = result.data.usertype;
								var roleId = result.data.roleId;
								localStorage.setItem("userId", result.data.userId);
								localStorage.setItem("token", result.data.token);
								localStorage.setItem("name", result.data.name);
								//判断权限
								if(roleId == 1) {
									localStorage.setItem("jurisdiction", '管理员');
								} else if(roleId == 12) {
									localStorage.setItem("jurisdiction", '客户');
								} else if(roleId == 13) {
									localStorage.setItem("jurisdiction", '供应商');
								} else if(roleId == 14) {
									localStorage.setItem("jurisdiction", '库存管理');
								} else if(roleId == 15) {
									localStorage.setItem("jurisdiction", 'onwer');
								}
								//判断用户类型
								if(usertype == 518) {
									window.location.href = 'manage.html';
								} else if(usertype == 5418) {
									window.location.href = 'manage.html';
								}
							} else {
								alert('账号密码不一致');
							}
							//var sb = JSON.stringify(result);
							//alert(sb);
							//alert(result.fileFullName);
							//alr re = JSON.parse(result);
							//ar re = JSON.stringify(result);
							//alert(re); 13168718182
							//$('#hidden1').value=result.sId;
							//document.getElementById("hidden1").value=result.sId;
						},
						error: function(data) { //若果传过来的数据为空
						}
					});
				});
			});
		</script>
	</head>

	<body background="#cccccc">
		<div>
			<img src="../img/logo.png" style="width: 15%; margin-top: 0%; margin-left: 0%;height:15px;" />
		</div>
		<font style="color: #2ce0fd; position: fixed; top: 26%; margin-left:24%;font-size: calc(25vw/3.75);font-weight:bold;">智慧工厂云平台</font>
		<div class="ficldser1">
			<input id="user" type="text" class="yonghuming" placeholder="请输入账号" />
			<span class="uesr-icon icon"></span>
		</div>
		<div class="ficldser2">
			<input id="password" type="password" class="yonghuming" placeholder="请输入密码" />
			<span class="password-icon icon"></span>
		</div>
		<div style="text-align: center;">
			<input id="thebuyer" class="loginbtn" type="button" value="登录" />
			<font style="color: #2ce0fd;font-size: calc(15vw/3.75);font-weight:bold;position:relative;top: 130px;">深圳聚特易技术有限公司</font>
		</div>
	</body>

</html>